GROUP BY clause:
    It is used to group the table records.

Rules for GROUP BY clause:
1. The number of columns used in the select statement should be same as the number of columns used in the GROUP BY clause.

2. The number of columns used in the GROUP BY clause need not to be same as number of columns used in the select statement

3. GROUP BY clause should be followed by WHERE clause.

4. The datatypes of the column used in the select statement should be same as datatypes of the column used in the GROUP BY clause.

5. If we use column name in select statement along with aggregate function, then we must use GROUP BY clause.


Q: Identify the number of employees in each departments from emp table?
Ans: 
select <colName1>,<colName2>, <aggregateFunction> (<colName3>) from <tableName> GROUP BY <colName1>,<colName2>;
Ex: select deptno, count(*) from emp group by deptno;


Q: display the no. of employees for the sales department?
Q: Display the no. of employees based on the job from emp table?

Q: Group the employee details based on the deptno?
Q: Group the employees from emp table based on the job?
Q: group based on job and deptno from emp table?
Q: group the EMP table details for salesman based on job and deptno from emp table?
Q: Display the total salary in the EMP table based on the job?
Q: Display the total salary in the EMP table based on the job especially for salesman?

